#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>


typedef int QueueDataType;

typedef struct QueueNode {
    QueueDataType val;
    struct QueueNode* next;
}QNode;

typedef struct Queue {
    QNode* phead;
    QNode* ptail;
    int size;
}Queue;

void QueueInit(Queue* pq) {
    assert(pq);
    pq->phead = NULL;
    pq->ptail = NULL;
    pq->size = 0;
}

bool QueueEmpty(Queue* pq) {
    assert(pq);
    return pq->phead == NULL;
}

void QueuePush(Queue* pq, QueueDataType x) {
    assert(pq);
    QNode* newnode = (QNode*)malloc(sizeof(QNode));
    newnode->val = x;
    newnode->next = NULL;
    if (pq->ptail == NULL) {
        pq->phead = pq->ptail = newnode;
    }
    else {
        pq->ptail->next = newnode;
        pq->ptail = newnode;
    }
    pq->size++;
}

void QueuePop(Queue* pq) {
    assert(pq);
    QNode* del = pq->phead;
    pq->phead = pq->phead->next;
    free(del);
    del = NULL;
    if (pq->phead == NULL) {
        pq->ptail = NULL;
    }
    pq->size--;
}

QueueDataType QueueFront(Queue* pq) {
    assert(pq);
    return pq->phead->val;
}

int QueueSize(Queue* pq) {
    assert(pq);
    return pq->size;
}

int main() {
    int x, n, cod;
    Queue q;
    QueueInit(&q);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &cod);
        if (cod == 1) {
            scanf("%d", &x);
            QueuePush(&q, x);
        }
        if (cod == 2) {
            if (QueueEmpty(&q)) {
                printf("lan\n");
            }
            else {
                QueuePop(&q);
            }
        }
        if (cod == 3) {
            if (QueueEmpty(&q)) {
                printf("qiao\n");
            }
            else {
                printf("%d\n", QueueFront(&q));
            }
        }
        if (cod == 4) {
            printf("%d\n", QueueSize(&q));
        }
    }
}